package Thread_Demo;class Counter{    public int count = 0;    public void add()    {        count++;    }    public int getCount(){return count;}}public class Demo5 {    public static void main(String[] args) {        Counter con = new Counter();        Thread t1 = new Thread(()->{            synchronized(con) {                for (int i = 0; i < 50000; i++) con.add();            }        });        Thread t2 = new Thread(()-> {            synchronized (con) {                for (int i = 0; i < 50000; i++) con.add();            }        });        t1.start();        t2.start();        try {            t1.join();            t2.join();        } catch (InterruptedException e) {            e.printStackTrace();        }        System.out.println(con.getCount());    }}